<?php
$smarty->configLoad($lang . '/shop.module.php');
$language = parse_ini_file($lang . '/breadcrumb.module.php', true);
$breadcrumb = $language['add_shop'];

$sql = 'SELECT * FROM '.DB_LOGIN.'.aionshop_categories';
$dbh = $connection->prepare($sql);
$dbh->execute();
foreach($dbh->fetchAll(PDO::FETCH_ASSOC) as $row){
	$value[] = $row;
}
if(isset($_POST['submit'])) {
	$main->logAction($_SESSION['id'], 'shop_add_log');
	$sql = 'INSERT INTO '.DB_LOGIN.'.aionshop_items (
		itemTemplateId, 
		itemCount, 
		itemCategory, 
		itemPrice, 
		itemName, 
		itemDesc, 
		itemEyecatch,
		itemClassRestrict,
		itemServerRestrict
		) VALUES (
		:itemTemplateId, 
		:itemCount, 
		:itemCategory, 
		:itemPrice, 
		:itemName, 
		:itemDesc, 
		:eyecatcher, 
		NULL,
		NULL)
		';
	$dbh = $connection->prepare($sql);
	if(isset($_POST['itemEyecatch'])) {
		$_POST['itemEyecatch'] = 1;
	} else {
		$_POST['itemEyecatch'] = 0;
	}
	$dbh->bindValue(':itemTemplateId', $_POST['itemTemplateId']);
	$dbh->bindValue(':itemCount', $_POST['itemCount']);
	$dbh->bindValue(':itemCategory', $_POST['itemCategory']);
	$dbh->bindValue(':itemPrice', $_POST['itemPrice']);
	$dbh->bindValue(':itemName', $_POST['itemName']);
	$dbh->bindValue(':itemDesc', $_POST['itemDesc']);
	$dbh->bindValue(':eyecatcher', $_POST['itemEyecatch']);
	$dbh->execute();
	$main->jqmodal('add');
	echo '<meta http-equiv="refresh" content="5; URL=index.php?mod=shop">';
}
$smarty->assign('from', $value);
$template = 'shop/item.tpl';
?>